import Vue from "vue";
import Vuex from "vuex";
import utils from "@/utils";
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    islogin: utils.localStore.get("islogin") || true,
  },
  mutations: {
    updateLocalStoreFn(state, data) {
      utils.localStore.set(data.key, data.data);
      state[data.key] = data.data;
    },

    updateFn(state, data) {
      if (data.key) {
        if (data.localStore) {
          this.commit("updateLocalStoreFn", {
            key: data.key,
            data: data.data
          });
        } else {
          state[data.key] = data.data;
        }
      }
    }
  },
  actions: {}
});
